External Configuration Store Pattern

This document describes the External Configuration Store Pattern example from the guide Cloud Design Patterns (see http://aka.ms/Cloud-Design-Patterns).

 


 

Before you start

 

Ensure that you have installed all of the software prerequisites. For details see the Release Notes.

 

The example demonstrates operational aspects of applications running in Windows Azure. Therefore, you will need to use the diagnostics tools in order to understand how the code sample works. You must ensure that the web and worker roles in the solution are configured to use the diagnostics mechanism. If not, you will not see the trace information generated by the example.

 


 

About the Example

 

This example shows a mechanism for storing configuration settings in an external store instead of using configuration files. In this example, settings are stored in Windows Azure Blob Storage. The blob containing the configuration information is monitored by an instance of the ExternalConfigurationManager class. When the ExternalConfigurationManager object detects a change in the configuration store, it notifies the application of the change.

 


 

Running the Example

 

This example can be run only in the local Windows Azure emulator.

 

  • Start Visual Studio using an account that has Administrator privileges ("Run as Administrator").
  • Open the solution you want to explore from the subfolders where you downloaded the examples.
  • Right-click on each role in Solution Explorer, select Properties, and ensure that the role is configured to generate diagnostic information.
  • Press F5 in Visual Studio to start the example running.
  • To simulate an external update to the configuration blob:
    • Open the NewConfiguration folder. This contains a version of the configuration blob with different values.
    • Upload this blob to the local Windows Azure emulator storage to replace the original. You can do this in the Storage section of Visual Studio Server Explorer.
    • Set two breakpoints in the method CheckForConfigurationChangesAsync in ExternalConfigurationManager.cs on the following lines:
      • await this.syncCacheSemaphore.WaitAsync(); // will break on every check.
      • this.settingsCache = latestSettings; // will break only when a new blob version is present.
    • View the Output Window to see the changes detected by the ExternalConfigurationManager.
  • Open the Windows Azure Compute Emulator UI from the icon in the notification area.
  • Select each role in turn and view the diagnostic information generated by Trace statements in the code.